import React, { Component } from 'react'
import { Button, Text, TextInput, View } from 'react-native'
export default class UserAddor extends Component {
    state={user:{}}
    _unameChange=uname=>{
        let user=this.state.user
        user.uname=uname
        this.setState({user})
    }
    _addressChange=address=>{
        let user=this.state.user
        user.address=address
        this.setState({user})
    }
    _add=()=>{
        this.props.onAddUser(this.state.user)
    }
    render() {
        return (
            <View>
                <TextInput placeholder="请输入姓名"
                 value={this.state.user.uname} onChangeText={this._unameChange}/>
                <TextInput  placeholder="请输入地址"
                 value={this.state.user.address} onChangeText={this._addressChange}/>
                <Button title="添加" onPress={this._add}/>
            </View>
        )
    }
}
